package com.upup.service.impl;

import com.upup.service.UserService;
import com.upup.model.*;

import java.util.List;

/**
 * Author: zhiye
 * Description:
 */
public class UserServiceImpl  implements UserService {
    @Override
    public boolean checkUsername(String username) {
        User user = new User();
        List<User> users = user.where("username",username).findAll();
        if(users.size()==0){
            return false;
        }else {
            return true;
        }
    }
    @Override
    public boolean checkEmail(String email) {
        User user = new User();
        List<User> users = user.where("email",email).findAll();
        if(users.size()==0){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public boolean saveUser(String username, String password, String email, String time) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setEmail(email);
        user.setPic(time);
        user.save();
        return true;
    }

    @Override
    public boolean checkUAP(String username, String password) {
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        User users = user.find();
        if(users !=null){
            return true;
        }else {
            return false;
        }
    }
}
